/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package image;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 *
 * @author Swang
 */
public class ImageMaigckProcess {
//
//    public static void main(String[] args) throws IOException, InterruptedException {
//        //String convertCmd = "C:\\apache-tomcat-5.5.34\\bin\\startup.bat";
//        String convertCmd = "\"C:/Program Files/ImageMagick-6.4.7-Q16/convert\" -resize \"1024x768\" c:\\tmp\\upload\\attach_b8b7d9c18c83c5f237616ea32df7e765.jpg z:/hengzhi_data/yoopay/collection_emap/map797.jpg";
//        Process proc = Runtime.getRuntime().exec(convertCmd);
//        proc.waitFor();
//    }
    
    static public void main(String[] args) {
        String cmd = "C:/Program Files/ImageMagick-6.4.7-Q16/convert";

        try {
            Process ps = Runtime.getRuntime().exec(cmd);
            System.out.print(loadStream(ps.getInputStream()));
            System.err.print(loadStream(ps.getErrorStream()));
        } catch(IOException ioe) {
            ioe.printStackTrace();
        }
    }

    // read an input-stream into a String
    static String loadStream(InputStream in) throws IOException {
        int ptr = 0;
        in = new BufferedInputStream(in);
        StringBuffer buffer = new StringBuffer();
        while( (ptr = in.read()) != -1 ) {
            buffer.append((char)ptr);
        }
        return buffer.toString();


    }
}
